﻿using System.Text;

namespace SL651Center2.x
{
    public static class ByteArrayExtensions
    {
        public static bool StartWith(this byte[] buffer, byte[] value)
        {
            return buffer.StartWith(0, value);
        }

        public static bool StartWith(this byte[] buffer, int startIndex, byte[] value)
        {
            if (buffer.Length - startIndex < value.Length)
                return false;
            for (var i = 0; i < value.Length; i++)
            {
                if (buffer[startIndex + i] != value[i])
                    return false;
            }
            return true;
        }
        public static string ToASCIIString(this byte[] buffer)
        {
            return Encoding.ASCII.GetString(buffer);
        }
    }
}
